import DataManager from "./core/DataManager";
import UIManager from "./core/UIManager";

cc.Class({
    extends: cc.Component,

    properties: {
        canvas: {
            default: null,
            type: cc.Node,
            tooltip: '场景画布'
        },
    },

    // LIFE-CYCLE CALLBACKS:

    onLoad () {
        DataManager.isAppGame =true;
        // appGame.gameServerRoom.on(consts.CLIENT_GAME_START, this.startCheckAppGame, this);
    },

    // startCheckAppGame(){
    //     DataManager.isAppGame =true;
    // },
    start() {
        cc.game.setFrameRate(60);
        this.gameMagr = this.canvas.getComponent("GameManager");
        this.canvas.active = true;
        if (UIManager&&UIManager.instance)
            UIManager.instance.load.open();
        DataManager.loadComfigDatas(this.onLoadComfigDatas.bind(this));
        if (appGame.platform != "chuanyinGame")
            DataManager.showBannerAd();
        DataManager.adInit()

        if (appGame.platform == "fh" || appGame.platform == "googleAD") {
            setTimeout(() => {
                // window.parent.postMessage("showInterstitial", "*");
            }, 1000);
     
            setInterval(() => {
     
                // window.parent.postMessage("showInter", "*");
            }, 30000);
        }
    },
    onLoadComfigDatas: function () {
        this.canvas.active = true;
        this.gameMagr.init();

    },

    // update (dt) {},
});
